﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UIT_CV_Management
{
    public partial class iMessageBox : Form
    {
        public iMessageBox()
        {
            InitializeComponent();
            InitLanguage();
        }

        public void InitLanguage()
        {
            try
            {
                btnNo.Text = Language._("MESSAGE_BOX_NO_BTN");
                btnYes.Text = Language._("MESSAGE_BOX_YES_BTN");
                btnOK.Text = Language._("MESSAGE_BOX_OK_BTN");
            }
            catch (Exception Err)
            {
                btnNo.Text = "No";
                btnYes.Text = "Yes";
                btnOK.Text = "OK";
            }
        }

        public DialogResult Show(IWin32Window _Parent, String _Text, String _Caption, 
            MessageBoxButtons _Buttons, MessageBoxIcon _Icon)
        {
            
            this.lblMessage.Text = _Text;
            this.Text = _Caption;
            switch (_Buttons)
            {
                case MessageBoxButtons.OK:
                    this.pnlButtonsOK.Visible = true;
                    this.AcceptButton = btnOK;
                    this.CancelButton = btnOK;
                    break;
                case MessageBoxButtons.YesNo:
                    this.pnlButtonsYesNo.Visible = true;
                    this.AcceptButton = btnYes;
                    this.CancelButton = btnNo;
                    break;
            }
            switch (_Icon)
            {
                case MessageBoxIcon.Error:
                    ptbIcon.Image = global::UIT_CV_Management.Properties.Resources.error;
                    break;
                case MessageBoxIcon.Information:
                    ptbIcon.Image = global::UIT_CV_Management.Properties.Resources.information;
                    break;
                case MessageBoxIcon.Warning:
                    ptbIcon.Image = global::UIT_CV_Management.Properties.Resources.warning;
                    break;
            }
            return this.ShowDialog(_Parent);
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.Text == "SQL Connection error")
                System.Diagnostics.Process.GetCurrentProcess().Kill();
        }
    }
}
